package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.DailyTrainSeatQueryDto;
import com.simon.train.business.dto.DailyTrainSeatSaveDto;
import com.simon.train.business.service.DailyTrainSeatService;
import com.simon.train.business.vo.DailyTrainSeatQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/dailyTrainSeat")
public class DailyTrainSeatAdminController {

    @Resource
    private DailyTrainSeatService dailyTrainSeatService;

    @PostMapping("/save")
    public Result<Object> SaveDailyTrainSeat(@Valid @RequestBody DailyTrainSeatSaveDto dailyTrainSeatSaveDto){
        dailyTrainSeatService.SaveDailyTrainSeat(dailyTrainSeatSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<DailyTrainSeatQueryVO>> DailyTrainSeatQueryList(@Valid DailyTrainSeatQueryDto dailyTrainSeatQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<DailyTrainSeatQueryVO> lists = dailyTrainSeatService.QueryDailyTrainSeatList(dailyTrainSeatQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteDailyTrainSeat(@PathVariable("id") Long id){
        dailyTrainSeatService.deleteDailyTrainSeat(id);
        return new Result<>();
    }

}
